import jsonpath
import json
import urllib.request
url = 'https://www.taopiaopiao.com/cityAction.json?activityId&_ksTS=1642686492364_108&jsoncallback=jsonp109&action=cityAction&n_s=new&event_submit_doGetAllRegion=true'

headers = {
#'authority':' www.taopiaopiao.com',
#'method':' GET',
#'path':' /cityAction.json?activityId&_ksTS=1642685981801_108&jsoncallback=jsonp109&action=cityAction&n_s=new&event_submit_doGetAllRegion=true',
#'scheme':' https',
'accept':' text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01',
#'accept-encoding':' gzip, deflate, br',
'accept-language':' zh-CN,zh;q=0.9',
'cookie':' t=8f73da72bccb1de6711282d60a18f6b5; _tb_token_=768e7e5db14ea; cookie2=19370704272348f02dc4b52784f2fb8f; cna=OjNwGuedAkICARvGVw7StGwr; xlly_s=1; tb_city=110100; tb_cityName="sbG+qQ=="; tfstk=cRxRB3j8Cjckj0WvQU3DRWMt6ZMGZmwRt81LvxWo0xi-eeZdipxMX5pnP95NwxC..; l=eBTe7jOng8wev8P8BOfwlurza77tcIRfguPzaNbMiOCP_W1H5qiGW6K1ttLMCnGVnsO6R3WK4ADbBYYLiy4eC3FmuMXJ8e6R6dTh.; isg=BPr6Emh6T5xGgsPwVj-QzmfnSyAcq36FEZUK1wTzwQ1Y95sx7DsmlOUJR4Mr5_Yd',
'referer':'https://dianying.taobao.com/',
'sec-ch-ua':' " Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
'sec-ch-ua-mobile':' ?0',
'sec-ch-ua-platform':' "Windows"',
'sec-fetch-dest':' empty',
'sec-fetch-mode':' cors',
'sec-fetch-site':' same-origin',
'user-agent':' Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36',
'x-requested-with':' XMLHttpRequest'
}

request = urllib.request.Request(url=url,headers=headers)

response = urllib.request.urlopen(request)

content = response.read().decode('utf-8')

content = content.split('(')[1].split(')')[0]

with open('tpp.json','w',encoding='utf-8')as fp:
    fp.write(content)

obj = json.load(open('tpp.json','r',encoding='utf-8'))

city_list = jsonpath.jsonpath(obj,'$..regionName')
print(city_list)